﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ECommerce.WebControls
{
    public class WebObjetoEditItem : System.Web.UI.WebControls.CompositeControl
    {
        private bool showIdentity;
        public bool ShowIdentity
        {
            get { return this.showIdentity; }
            set { this.showIdentity = value; }
        }
        public System.Web.UI.WebControls.TextBox txtId;
        public System.Web.UI.WebControls.TextBox txtDenominación;
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (txtId == null)
                txtId = new System.Web.UI.WebControls.TextBox();
            if (txtDenominación == null)
                txtDenominación = new System.Web.UI.WebControls.TextBox();
            txtId.SkinID = "CamposId";
            txtDenominación.SkinID = "CamposDenominación";
        }
        virtual public void Load(int ident)
        {
            ECommerce.Model.Objeto Objeto = new ECommerce.Model.Objeto();
            Objeto.Load(ident);
            this.Load(Objeto);  
        }
        virtual public void Load(ECommerce.Model.Objeto Objeto)
        {
            this.txtId.Text = Objeto.Id.ToString();
            this.txtDenominación.Text = Objeto.Denominación.ToString();
            if (!this.ShowIdentity)
                this.txtId.Style.Add("display", "none");
            this.Controls.Add(txtId);
            this.Controls.Add(txtDenominación);
        }
        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            RenderContents(writer);
        }
    }
}
